package com.darren.archive.entity;

import com.darren.framework.entity.BaseEntity;
import com.darren.framework.utils.Constant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.ResultCheckStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;

/**
 * 角色实体，数据表增删改查时使用的实体对象。
 *
 * @author: 周金涛
 * @date: 2019/8/21 15:12
 */
@ApiModel(value = "角色信息")
@Entity
@Table(name = Constant.TABLE_NAME_PREV + "roles")
@SQLDelete(sql = "update " + Constant.TABLE_NAME_PREV + "roles set is_delete = true,version=version+1 where id=? and version=? ", check = ResultCheckStyle.COUNT)
@Where(clause = " is_delete  = false or is_editable = false  ")
public class SysRole extends BaseEntity implements Serializable {


    private static final long serialVersionUID = -5313392341436938277L;
    /**
     * 角色名称
     */
    @ApiModelProperty(notes = "角色名称")
    @Column(name = "title", columnDefinition = "varchar(60) default '' comment '角色名称'")
    private String name;

    /**
     * 图标
     */
    @ApiModelProperty(notes = "图标")
    @Column(name = "icon", columnDefinition = "varchar(128) default '' comment '图标'")
    private String icon;


    /**
     * 显示顺序
     */
    @ApiModelProperty(example = "1000", notes = "显示顺序，数字类型，非空。确定在界面上的显示顺序")
    @Column(name = "display_sequence", columnDefinition = "int(10) default '100' comment '显示顺序'")
    private Integer displaySequence;

    /**
     * 是否允许编辑 true：可编辑，false：不可编辑。内置的角色不允许编辑
     */
    @ApiModelProperty(notes = "是否允许编辑 true：可编辑，false：不可编辑。内置的角色不允许编辑")
    @Column(name = "is_editable", columnDefinition = "tinyint default 0 comment '是否允许编辑 1：可编辑，0：不可编辑。内置的角色不允许编辑'")
    private boolean editable = true;

    /**
     * 是否启用。false：禁用  true：启用
     */
    @ApiModelProperty(notes = "是否启用。false：禁用  true：启用")
    @Column(name = "is_enable", columnDefinition = "tinyint default 0 comment '是否启用。false：禁用  true：启用'")
    private Boolean enable;

    /**
     * 功能数组
     */
    @Transient
    private Long[] functionIds;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public Integer getDisplaySequence() {
        return displaySequence;
    }

    public void setDisplaySequence(Integer displaySequence) {
        this.displaySequence = displaySequence;
    }


    public boolean isEditable() {
        return editable;
    }

    public void setEditable(boolean editable) {
        this.editable = editable;
    }

    public Boolean isEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public Long[] getFunctionIds() {
        return functionIds;
    }

    public void setFunctionIds(Long[] functionIds) {
        this.functionIds = functionIds;
    }

}